<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<html>
<body class="easyui-layout list_body">
	<form id="menuForm" name="menuForm">
		<div class="list_body_north" data-options="region:'north'" border="false">
			<!-- 查询表单 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				<div>
					<span>清算开始日期:</span>
					<input type="text" id="stl_dt_start" value="${yestedayDate}" name="stl_dt_start" class="easyui-datebox" data-options="editable:false"/>
					<span>清算结束日期:</span>
					<input type="text" id="stl_dt_end" value="${yestedayDate}" name="stl_dt_end" class="easyui-datebox" data-options="editable:false"/>
					<span>机构号:</span>
					<input type="text" id="ins_cd" name="ins_cd" class="easyui-textbox" />
					<span>机构名称:</span>
					<input type="text" id="ins_name" name="ins_name" class="easyui-textbox" /> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-search" onclick="doSearch()">查询</a> 
					<a href="#" class="easyui-linkbutton btn" iconCls="icon-reload" onclick="resetForm()">重置</a>
				</div>
			</div>
			<!-- 维护汇总数据 -->
			<div style="padding: 3px" class="easyui-panel datagrid-toolbar">
				总交易笔数：<span id="count_cnt"></span> 
				总交易金额：<span id="sum_amt"></span> 
				总下级分润：<span id="sum_lower_profit_amt"></span> 
				总机构分润：<span id="sum_profit_amt"></span>
				总会员手续费：<span id="sum_midfee"></span>
				总会员结算手续费：<span id="sum_custom_stl_fee"></span>
				总机构结算手续费：<span id="sum_ins_stl_fee"></span>
			</div>
			<jiepos:buttonOperateTag menuCode="${menuCode }"></jiepos:buttonOperateTag>
		</div>
		<div data-options="region:'center'" border="false" class="list_body_center">
			<!-- 表格 -->
			<table id="menuTableId" fit="true"></table>
		</div>
	</form>
</body>
<script type="text/javascript">
	var grid;
	$(function() {
		getTotalInfo();
		/*加载表格数据*/
		grid = $("#menuTableId").jpgrid({
			url : "getLogInsCommProfitSumListJson.do",
			baseColumns: false,
			columns : [ {
				title : "清算日期",
				field : "STL_DT",
				align : 'center',
				width : 100
			}, {
				title : "机构号",
				field : "INS_CD",
				align : 'center',
				width : 100
			}, {
				title : "机构名称",
				field : "INS_CN_NM",
				align : 'center'
			}, {
				title : "业务名称",
				field : "SERVICE_NAME",
				align : 'center'
			}, {
				title : "业务参数名称",
				field : "SERVICE_PARAM_NAME",
				align : 'center'
			}, {
				title : "交易笔数",
				field : "CNT",
				align : 'center',
				width : 100
			}, {
				title : "交易金额",
				field : "AMT",
				align : 'center',
				width : 100
			}, {
				title : "会员手续费",
				field : "MIDFEE",
				align : 'center',
				width : 100
			}, {
				title : "会员结算手续费",
				field : "CUSTOM_STL_FEE",
				align : 'center',
				width : 100
			}, {
				title : "机构结算手续费",
				field : "INS_STL_FEE",
				align : 'center',
				width : 100
			}, {
				title : "机构毛利",
				field : "PROFIT_AMT",
				align : 'center',
				width : 100
			}, {
				title : "下级分润",
				field : "LOWER_PROFIT_AMT",
				align : 'center',
				width : 100
			}]
		});
		

	});

	function doSearch() {
		grid.load({
			stl_dt_start : $('#stl_dt_start').val(),
			stl_dt_end : $('#stl_dt_end').val(),
			ins_cd : $('#ins_cd').val(),
			ins_name : $('#ins_name').val()
		});
		getTotalInfo();
	}
	
	function exportFile(url) {
		commonFileDownload(url, "menuForm");
	}
	
	function getTotalInfo(){
		var data = {
				stl_dt_start : $('#stl_dt_start').val(),
				stl_dt_end : $('#stl_dt_end').val(),
				ins_cd : $('#ins_cd').val(),
				ins_name : $('#ins_name').val()
		};
		$.ajax({
			url : '../logInsCommProfitSum/getLogStlMchntInfoTotal.do',
			data : data,
			success : function(result) {
				$("#count_cnt").html(result.COUNT_CNT);
				$("#sum_amt").html(result.SUM_AMT);
				$("#sum_lower_profit_amt").html(result.SUM_LOWER_PROFIT_AMT);
				$("#sum_midfee").html(result.SUM_MIDFEE);
				$("#sum_profit_amt").html(result.SUM_PROFIT_AMT);
				$("#sum_custom_stl_fee").html(result.SUM_CUSTOM_STL_FEE);
				$("#sum_ins_stl_fee").html(result.SUM_INS_STL_FEE);
			}
		});
	}
</script>
</html>
